package com.lions.client.view.audio;

import com.google.gwt.dom.client.AudioElement;
import com.google.gwt.media.client.Audio;

public class AudioOutput {

	public AudioOutput() {
		// Get the audio format type MP3
		type_mp3 = AudioElement.TYPE_MP3;

	}

	/**
	 * Plays an alert if selected bas is not available
	 */
	public void playBaseError() {
		if (Audio.isSupported()) {
			Audio error = Audio.createIfSupported();
			error.addSource("sounds/error.mp3", type_mp3);
			error.load();
			error.play();
		}
	}

	/**
	 * Sound to alert once minimum configuration is available
	 */
	public void playNewBase() {
		if (Audio.isSupported()) {
			Audio newBase = Audio.createIfSupported();
			newBase.addSource("sounds/tada.mp3", type_mp3);
			newBase.load();
			newBase.play();
		}
	}

	/**
	 * Sound for adding modules
	 */
	public void playAddModule() {
		if (Audio.isSupported()) {
			Audio addModule = Audio.createIfSupported();
			addModule.addSource("sounds/addmodule.mp3", type_mp3);
			addModule.load();
			addModule.play();
		}
	}

	/**
	 * Sound for editing modules
	 */
	public void playEditModule() {
		if (Audio.isSupported()) {
			Audio addModule = Audio.createIfSupported();
			addModule.addSource("sounds/editmodule.mp3", type_mp3);
			addModule.load();
			addModule.play();
		}
	}

	public void playStorageSaved() {
		if (Audio.isSupported()) {
			Audio addModule = Audio.createIfSupported();
			addModule.addSource("sounds/saved.mp3", type_mp3);
			addModule.load();
			addModule.play();
		}
	}

	/**
	 * Sound for removing modules
	 */
	public void playRemoveModule() {
		if (Audio.isSupported()) {
			Audio removeModule = Audio.createIfSupported();
			removeModule.addSource("sounds/removemodule.mp3", type_mp3);
			removeModule.load();
			removeModule.play();
		}
	}

	/**
	 * Sound when you clear the HTML5 session storage
	 */
	public void playClearStorage() {
		if (Audio.isSupported()) {
			Audio clearHTMLStorage = Audio.createIfSupported();
			clearHTMLStorage.addSource("sounds/recycle.mp3", type_mp3);
			clearHTMLStorage.load();
			clearHTMLStorage.play();
		}
	}

	/**
	 * In the module entry this will sound if the input is incorrect
	 */
	public void playInputError() {
		if (Audio.isSupported()) {
			Audio inputError = Audio.createIfSupported();
			inputError.addSource("sounds/ding.mp3", type_mp3);
			inputError.load();
			inputError.play();
		}
	}

	/**
	 * Plays an awesome song http://www.youtube.com/watch?v=dsU3B0W3TMs
	 */
	public void playWindowsSong() {
		if (Audio.isSupported()) {
			Audio inputError = Audio.createIfSupported();
			inputError.addSource("sounds/awesomesong.mp3", type_mp3);
			inputError.load();
			inputError.play();
		}
	}
	
	/**
	 * Plays We Ready.
	 */
	public void playReadySong() {
		if (Audio.isSupported()) {
			Audio inputError = Audio.createIfSupported();
			inputError.addSource("sounds/ready.mp3", type_mp3);
			inputError.load();
			inputError.play();
		}
	}
	
	/**
	 * Plays Login Sound.
	 */
	public void playLogin() {
		if (Audio.isSupported()) {
			Audio inputError = Audio.createIfSupported();
			inputError.addSource("sounds/login.mp3", type_mp3);
			inputError.load();
			inputError.play();
		}
	}

	private String type_mp3;

}
